package Box2D.Collision.Shapes
{
	import Box2D.Common.Math.b2Vec2;
	import Box2D.Common.Math.b2Vec2Array;
	import Box2D.Common.b2Settings;

	public class b2PolygonShape extends b2Shape
	{
		private var _centroid:b2Vec2;
		private var _vertices:Vector.<b2Vec2>;
		public function b2PolygonShape()
		{
			super(callDirect('b2PolygonShape_new'));
			_centroid = new b2Vec2(0,0,_wrapper+12);
			_vertices = new Vector.<b2Vec2>;
			for(var i:int=0;i<b2Settings.b2_maxPolygonVertices;i++){
				_vertices.push(new b2Vec2(0,0,_wrapper+12+8+8*i));
			}			
		}
		public function get centroid():b2Vec2{return _centroid}
		public function get vertices():Vector.<b2Vec2>{return _vertices}
		public function Set(vertices:b2Vec2Array,vertexCount:int):void{
			call('b2PolygonShape_Set',vertices.wrapper,vertexCount);
		}
		public function SetAsBox(hx:Number,hy:Number):void{
			call('b2PolygonShape_SetAsBox',hx,hy);
		}
		public function SetAsBoxByCenter(hx:Number,hy:Number,center:b2Vec2,angle:Number):void{
			call('b2PolygonShape_SetAsBoxByCenter',hx,hy,center.wrapper,angle);
		}
		public function GetVertexCount():int{
			return call('b2PolygonShape_GetVertexCount');
		}		
	}
}